package com.gree.design_patterns.chain;


import com.gree.design_patterns.chain.filter.OneFilter;
import com.gree.design_patterns.chain.filter.TwoFilter;
import com.gree.design_patterns.chain.paramter.Responses;
import com.gree.design_patterns.chain.paramter.Requests;

/**
 * @Auther: lyg
 * @Data: 2022/9/1
 */
public class ClientDemo {

    /**
     * 责任链模式
     */
    public static void main(String[] args) {
        // 创建责任链, 添加处理节点
        HandlerChain chain = new HandlerChain();
        chain.addChain(new OneFilter()).addChain(new TwoFilter());

        Requests requests = new Requests();
        requests.setMsgData("one two three ten");
        Responses responses = new Responses();
        responses.setMsgData("后置执行器开始go:");
        chain.doFilter(requests, responses);

        System.out.println(responses.getMsgData());
    }
}
